package com.camera2.local;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPrefer {

    public static void SaveToken(Context context, String token)
            throws Exception {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString("token", token);
        editor.commit();
    }

    public static String ReadToken(Context context) {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        String token = sp.getString("token", "");
        return token;

    }

    public static void SaveAutoUpdate(Context context, Boolean toggle) throws Exception {
        SharedPreferences sp = context.getSharedPreferences("Setupinfo",
                Context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putBoolean("toggle", toggle);
        editor.commit();
    }

    public static Boolean ReadAutoUpdate(Context context) {
        SharedPreferences sp = context.getSharedPreferences("Setupinfo",
                Context.MODE_PRIVATE);
        Boolean toggle = sp.getBoolean("toggle", false);
        return toggle;

    }






    public static void Saveid(Context context, String appid)
            throws Exception {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString("id", appid);
        editor.commit();
    }

    public static String Readid(Context context) {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        String appid = sp.getString("id", "");
        return appid;

    }

    public static void SaveUsername(Context context, String username)
            throws Exception {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString("username", username);
        editor.commit();
    }

    public static String ReadUsername(Context context) {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        String username = sp.getString("username", "");
        return username;

    }


    public static void SavePassword(Context context, String password)
            throws Exception {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString("password", password);
        editor.commit();
    }

    public static String ReadPassword(Context context) {
        SharedPreferences sp = context.getSharedPreferences("Userinfo",
                Context.MODE_PRIVATE);
        String password = sp.getString("password", "");
        return password;

    }
}
